#include <iostream>
#include <thread>
#include <mutex>

std::mutex mtx; // 定义互斥锁

void threadFunction() {
    mtx.lock(); // 加锁
    std::cout << "Hello from thread!" << std::endl;
    mtx.unlock(); // 解锁
}

int main() {
    std::thread t1(threadFunction);
    std::thread t2(threadFunction);
    t1.join();
    t2.join();
    std::cout << "Hello from main thread!" << std::endl;
    return 0;
}